package com.tth.learn.addproperties.java1;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @Author tth
 * @Date 2023/1/3 15:05
 */
public class Person {
    private Integer id;
    private String name;
    private Integer age;
    private double salary;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public Person(Integer id, String name, Integer age, double salary) {
        this.name = name;
        this.age = age;
        this.id = id;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Double.compare(person.salary, salary) == 0 &&
                name.equals(person.name) &&
                age.equals(person.age) &&
                id.equals(person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, id, salary);
    }

    // 帘外雨潺潺，春意阑珊。罗衾不耐五更寒。梦里不知身是客，一晌贪欢。
    // 独自莫凭栏，无限江山，别时容易见时难。流水落花春去也，天上人间。
    public static List<Person> getPersons() {
        return new ArrayList<Person>(){
            { add(new Person(1001, "张潺潺", 18, 5600)); }
            { add(new Person(1002, "李外雨", 17, 7200)); }
            { add(new Person(1003, "赵春意", 16, 3400)); }
            { add(new Person(1004, "宋阑珊", 20, 8900)); }
            { add(new Person(1005, "罗衾寒", 19, 5400)); }
            { add(new Person(1005, "罗衾寒", 19, 5400)); }
            { add(new Person(1006, "诸葛贪欢", 18, 7400)); }
            { add(new Person(1007, "白梦", 18, 2100)); }
        };
    }
}
